﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/style1.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/style4.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.showModalDialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        //时间格式转换
        function date2str(date) {
            //null判断
            if (date == null) return "";
            //去掉左右的斜杠
            date = date.replace(/\//g, "");
            //将其转为一个日期对象
            eval("var d = new " + date + ";");
            //返回最终结果
            return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
        };
        //得到ID
        var ID = window.dialogArguments.id;
        
        //加载显示
        $(function () {

            reloadList();
        });
        function reloadList() {
            //通过id将资料从数据库中查询出来
            $.ajax({
                url: "QuanBuAll.asmx/FindLinkMans",
                type: "post",
                data: JSON.stringify({ id: parseInt(ID) }),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    $("#Text0").val(obj.d.LMName) || "";
                    if (obj.d.LMSex == "男") $("#sex0").attr("checked", true) || "";
                    if (obj.d.LMSex == "女") $("#sex1").attr("checked", true) || "";
                    $("#Text1").val(obj.d.LMDuty) || "";
                    $("#Text2").val(obj.d.LMOfficeNo) || "";
                    $("#Text3").val(obj.d.LMMobileNo) || "";
                    $("#txtbz").val(obj.d.LMMemo) || "";
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        };
        //确认操作修改
        function ok() {
            var link = {
                action: "LinkManEdit",
                LMID: ID,
                LMName: $("#Text0").val(),
                LMSex: ($("#sex0").is(":checked") ? "男" : "女"),
                LMDuty: $("#Text1").val(),
                LMOfficeNo: $("#Text2").val(),
                LMMobileNo: $("#Text3").val(),
                LMMemo: $("#txtbz").val()
            };
            //alert(666);
            //发起更新请求
            $.get("CustomerAll.ashx", link, function (r) {
                if (r == "1") {
                    alert("修改成功");
                    window.returnValue = true;
                    window.close();
                } else {
                    alert("修改失败");
                }
            });
        };

    </script>
</head>
<body>
    <table class="tableEdit" id="tab">
        <thead>
            <tr>
                <td colspan="4">编辑联系人</td>
            </tr>
        </thead>
        <tr>
            <th>姓名：</th>
            <td>
                <input type="text" id="Text0" style="color:blue;width:100px"/></td>
            <th>性别：</th>
            <td>
                <input type="radio" id="sex0" />男&nbsp;&nbsp;<input type="radio" id="sex1" />女
            </td>
        </tr>
        <tr>
            <th>职位：</th>
            <td><input type="text" id="Text1" style="color:blue;width:100px" /></td>
            <th>固定电话：</th>
            <td><input type="text" id="Text2" style="color:blue;width:80px" /></td>
        </tr>
         <tr>
            <th>手机号码：</th>
            <td><input type="text" id="Text3" style="color:blue;width:85px" /></td>
            <th></th>
            <td><label id="kong"></label></td>
        </tr>
        <tr>
            <th>备注：</th>
            <td colspan="3"><textarea id="txtbz" style="color:blue;width:100%" /></textarea></td>
        </tr>
        <tfoot>
            <tr>
                <td colspan="4">
                    <input type="button" value="确定" onclick="ok();" />&nbsp;&nbsp;
                    <input type="button" value="关闭" onclick="window.close()" />
                </td>
            </tr>
        </tfoot>
    </table>
</body>
</html>
